'use strict';
const {getDefaultModelConfig} = require("../../utils/common");

module.exports = app => {
    const { STRING, INTEGER, DATE, TINYINT, BIGINT } = app.Sequelize;
    const TicketLineRecord = app.model.define(
        'TicketLineRecord',
        {
            id: {type: BIGINT, primaryKey: true, autoIncrement: true},
            ticket_line_id: {type: BIGINT, allowNull: false, comment: '线路ID'},
            phone: {type: STRING(20), allowNull: false, comment: '联系电话'},
            name: {type: STRING(50), allowNull: false, comment: '联系人姓名'},
            travel_date: {type: DATE, allowNull: false, comment: '预约日期'},
            user_id: {type: BIGINT, allowNull: false, comment: '用户ID'},
            people_count: {type: INTEGER, allowNull: true, defaultValue: 1, comment: '预约人数'},
            status: {
                type: TINYINT,
                allowNull: false,
                defaultValue: 1,
                comment: '状态(0-取消,1-待使用,2-已使用)'
            },
            ...getDefaultModelConfig(app)
        },
        {
            tableName: 'ticket_line_record',
            timestamps: true,
            createdAt: 'create_time',
            updatedAt: 'update_time'
        }
    );
    return TicketLineRecord
};
